<div class="admin-biaogelist">

    <div class="listbiaoti am-cf">
        <ul class="am-icon-flag on">已完成任务</ul>


        <!--<dl>
          <button type="button" class="am-btn am-btn-danger am-round am-btn-xs am-icon-plus" > 补充线订单</button>
        </dl>-->
        <!--这里打开的是新页面-->

    </div>

    <div class="fbneirong" style="min-height: 790px" id="dphjtbox">

        <div id="dphjt">
            <div class="hang">
                <el-form ref="form" :model="form">
                    <el-form-item label="订单号:" prop="orderid" class="itemInput" label-width="80px">
                        <el-input v-model="form.orderid" placeholder=""/>
                    </el-form-item>

                    <el-form-item label="任务ID:" prop="taskid" class="itemInput" label-width="80px">
                        <el-input v-model="form.taskid" placeholder=""/>
                    </el-form-item>

                    <el-form-item label="商铺名:" prop="shop_name" class="itemInput" label-width="80px">
                        <el-input v-model="form.shop_name" placeholder="请输入商铺名"/>
                    </el-form-item>


                    <el-form-item label="awz:" prop="awz" class="itemInput" label-width="80px">
                        <el-input v-model="form.awz" placeholder="请输入awz"/>
                    </el-form-item>


                    <el-form-item label-width="80px" label="开始时间:" class="itemdate" prop="date">
                        <el-date-picker style="width: 180px"
                                        v-model="form.date1"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                        </el-date-picker>
                    </el-form-item>

                    <el-form-item label-width="80px" label="结束时间:" class="itemdate" prop="date">
                        <el-date-picker style="width: 180px"
                                        v-model="form.date2"
                                        type="date"
                                        placeholder="选择日期"
                                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                        </el-date-picker>
                    </el-form-item>

                    <el-form-item label-width="80px" label="类型:" class="sourcedate" prop="type_h">
                        <el-select style="width:100px" v-model="form.type_h" placeholder="状态" claer>
                            <el-option

                                    key=""
                                    label="全部"
                                    value="">
                            </el-option>
                            <el-option
                                    v-for="(value,key) in type_hlist"
                                    :key="key"
                                    :label="value"
                                    :value="key">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item class="itembtn" label-width="40px">
                        <el-button type="primary" size="small" @click="getdata">获取数据</el-button>
                    </el-form-item>
                </el-form>

            </div>
            <div class="hang" style="margin: 5px 0px;">

                <div style="width: 100%;float: left">
                    <div class="hang title"><span>任务列表</span></span>

                        <!--   <input  type="file" name="uploadFile" class="uploadPicButton" id="upload_file"   value="上传订单" >-->
                        <el-upload
                                class="upload-demo"
                                :action="uploadurl()"
                                :on-change="handleChange"
                                :show-file-list="false"
                                :on-success="uploadsuccess"
                        >
                            <el-button size="mini" type="success" icon="el-icon-upload
" icon="el-icon-upload
" type="primary">上传订单
                            </el-button>

                        </el-upload>
                        <el-button type="primary" size="mini" icon="el-icon-download" @click="getexcel">导出订单</el-button>
                    </div>
                    <el-table v-loading="listLoading" :data="list.llly.list"
                              :row-style="{height:'20px'}"
                              :cell-style="{padding:'4px'}"

                              element-loading-text="加载中" fit highlight-current-row>
                        <el-table-column label="ID" prop="id"
                                         align="center">
                        </el-table-column>
                        <el-table-column label="完成时间" prop="finishtime"
                                         align="center">
                        </el-table-column>
                        <el-table-column label="类型" prop="type_h"
                                         align="center">
                            <template slot-scope="scope">
                                {{type_hlist[scope.row.type_h]}}
                            </template>
                        </el-table-column>

                        <el-table-column label="店铺名称" prop="shop_name"
                                         align="center">
                        </el-table-column>
                        <el-table-column label="任务ID" prop="taskid"
                                         align="center">
                        </el-table-column>

                        <el-table-column label="每单件数" prop="number"
                                         align="center">
                        </el-table-column>

                        <el-table-column label="关键字" prop="keyword"
                                         align="center">
                        </el-table-column>


                        <el-table-column label="评论" align="center" prop="text" width="120px"
                                         :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{scope.row.text}} </span>
                            </template>
                        </el-table-column>

                        <el-table-column label="个性化" align="center" width="120px" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                             <span style="color: red" v-show="scope.row.type_h==1">
                              <span v-show="scope.row.overnight==1">隔夜收藏</span>

                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column label="订单号" align="center" width="250px">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.orderid" placeholder="订单号"/>
                            </template>
                        </el-table-column>
                        <el-table-column label="实际付款" align="center">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.real_price" placeholder="付款"/>
                            </template>
                        </el-table-column>

                        <el-table-column label="AWZ" align="center">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.awz" placeholder="AWZ"/>
                            </template>
                        </el-table-column>


                        <el-table-column label="操作" align="center" width="100px">
                            <template slot-scope="scope">
                                <el-button type="primary" size="small" @click="setstatus(scope.row)">修改</el-button>

                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="hang pagination">
                        <el-pagination background @current-change="current_change" layout="total,prev, pager, next"
                                       :page-size="this.pagesize" :total="list.llly.total"></el-pagination>
                    </div>
                </div>


            </div>
        </div>


    </div>


    <script>

        new Vue({
            el: '#dphjtbox',
            filters: {
                statusFilter(status) {
                    const statusMap = {
                        0: 'gray',
                        1: 'success',
                        2: 'success',
                        3: 'info',
                        4: 'danger',
                    };
                    return statusMap[status]
                }
            },
            data() {
                return {
                    dialogtable: true,
                    dialogtablefenxi: false,
                    tabletitelfenxi: "",
                    listLoading: false,
                    type_hlist: {
                        1: "普通单",
                        2: "高留评",
                        3: "多多进宝",
                        4: "拼多多直播",
                    },
                    overnightlist: ["非隔夜单", '隔夜单'],

                    select: {
                        status: ["未发布", "已发布", "已发布(1)", "已完成(2)", "已废除"]
                    },
                    form: {
                        id: "",
                        orderid: "",
                        awz: "",
                        shop_name: "",
                        date1: "",
                        date2: "",
                        type_h: "",
                        taskid: "",
                        overnight: "",
                    },
                    type: "line",
                    list: {
                        productInfo: null,
                        gjclist: {
                            currpage: 1,
                            list: [],
                            total: 0
                        },
                        llly: {
                            currpage: 1,
                            list: [],
                            total: 0
                        },
                        fenxi: {
                            currpage: 1,
                            list: [],
                            total: 0
                        },

                    },
                    currpage: 1,
                    pagesize: 10,
                    tabletitel: "",


                }
            },
            created() {
                var today = toolCase.getDateStr(0)
                this.form.date1 = today + " 00:00:00";
                this.form.date2 = today + " 23:59:59";

                this.getdata()
            },

            methods: {
                handleChange(file, fileList) {

                },
                uploadurl() {
                    return "<?php echo base_url(); ?>/hunter/excelToArray";
                },
                uploadsuccess(response, file, fileList) {
                    if (response.code == 0) {
                        this.$message({
                            message: "订单完成",
                            type: 'success',
                            offset: 300,
                            duration: 1500
                        });
                        return
                    }
                    this.$message({
                        message: response.msg,
                        type: 'warning',
                        offset: 300,
                        duration: 1500
                    });
                },

                getexcel() {
                    let post = this.form;
                    var url = "<?php echo base_url(); ?>/hunter/getpddfinishlist";
                    post.epage = 3000;
                    post.page = 1;
                    post.getexcel = 1;
                    const form = document.createElement('form')
                    form.id = "downloadform"
                    form.style.display = 'none' //将表单隐藏
                    form.target = ''
                    form.method = 'post'
                    form.action = url

                    $.each(post, function (i, v) {
                        var input = document.createElement('input')
                        input.type = 'hidden'
                        input.name = i
                        input.value = v
                        form.appendChild(input)
                    })

                    document.body.appendChild(form)
                    form.submit()
                    document.body.removeChild(form) // 释放标签


                },
                getdata() {
                    let post = this.form;
                    let that = this;
                    post.page = this.currpage;

                    var url = "<?php echo base_url(); ?>/hunter/getpddfinishlist";
                    $.ajax({
                        url: url,
                        type: "POST",
                        dataType: "json",
                        data: post,
                        success: function (res) {
                            if (res.code != 0) {
                                that.$message({
                                    message: res.msg,
                                    type: 'warning',
                                    offset: 300,
                                    duration: 1500
                                });
                            } else {
                                that.list.llly.list = res.list;
                                that.list.llly.total = res.count;
                            }
                        }
                    })


                },
                current_change(currentPage) {
                    this.currpage = currentPage;
                    this.getdata();
                },

                setstatus(row) {
                    this.$confirm('确认修改该任务', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        this.sendchange(row);
                    }).catch(() => {

                    });
                },

                sendchange(row) {
                    var postdata = {
                        'id': row.id,
                        'orderid': row.orderid,
                        'awz': row.awz,
                        'real_price': row.real_price
                    };
                    let that = this;
                    var url = "<?php echo base_url(); ?>/hunter/JdEdite";
                    $.ajax({
                        url: url,
                        type: "POST",
                        dataType: "json",
                        data: postdata,
                        success: function (res) {
                            if (res.code != 0) {
                                that.$message({
                                    message: res.msg,
                                    type: 'warning',
                                    offset: 300,
                                    duration: 1500
                                });
                            } else {
                                that.$message({
                                    message: "修改成功",
                                    type: 'success',
                                    offset: 300,
                                    duration: 1500
                                });
                                that.getdata(1);
                            }
                        }
                    })
                }
            }
        })
    </script>

    <style>
        .el-form {
            height: auto;
            overflow: hidden;
            padding: 10px;
        }

        .uploadPicButton {
            display: inline-block !important;
            float: right;
            width: 200px !important;
        }

        .el-upload__input {
            display: none !important;
        }

        .upload-demo {
            display: inline-block;
            width: auto;
            float: right;

        }

        #dphjt input {
            width: 100%;
        }

        #dphjt .itemInput {
            width: 240px;
            float: left;
        }

        #dphjt .itemdate {
            width: 240px;
            float: left;
        }

        #dphjt .itembtn {
            width: 120px;
            float: left;
        }

        #dphjt .sourcedate {
            width: 150px;
            float: left;
        }


        #dphjt .title {
            border-left: solid 2px #5a5abf;
        }

        #dphjt .title .el-button {
            float: right;
            margin-right: 15px;
        }

        #dphjt .title > span:first-child {
            margin-left: 10px;
            font-weight: 700;
        }

        .hang {
            width: 100%;
            height: auto;
            overflow: hidden;
            padding: 8px 0px;
        }
    </style>
